package com.ctshk.rpc.order.tour.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ctshk.rpc.order.tour.dto.SeriesOrderReceiptListPageDTO;
import com.ctshk.rpc.order.tour.dto.SeriesOrderReceiptListTouristDTO;
import com.ctshk.rpc.order.tour.dto.SeriesOrderReceiptListTouristPageDTO;
import com.ctshk.rpc.order.tour.dto.custom.CustomOrderReceiptListDTO;
import com.ctshk.rpc.order.tour.dto.custom.CustomOrderReceiptListTouristDTO;
import com.ctshk.rpc.order.tour.dto.custom.CustomOrderReceiptListTouristPageDTO;
import com.ctshk.rpc.order.tour.entity.SeriesOrderReceipt;
import com.ctshk.rpc.order.tour.req.SeriesOrderReceiptListReq;
import com.ctshk.rpc.order.tour.req.SeriesOrderReceiptListTouristReq;
import com.ctshk.rpc.order.tour.req.custom.CustomOrderReceiptListTouristReq;
import com.ctshk.rpc.order.tour.req.custom.OrderReceiptListReq;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

/**
 * <p>
 * 系列团订单收据 Mapper 接口
 * </p>
 *
 * @author 谭响
 * @since 2021-02-01
 */
public interface SeriesOrderReceiptMapper extends BaseMapper<SeriesOrderReceipt> {

    @SelectProvider(type = SeriesOrderReceiptProvider.class, method = "selectListBySelective")
    IPage<CustomOrderReceiptListDTO> selectListBySelective(IPage<OrderReceiptListReq> pageParam, @Param("req") OrderReceiptListReq req);

    /**
     * 打印收据-旅客列表
     * @param req
     * @return
     */
    @SelectProvider(type = SeriesOrderReceiptProvider.class, method = "selectListTouristBySelective")
    IPage<CustomOrderReceiptListTouristPageDTO> selectListTouristBySelective(IPage<CustomOrderReceiptListTouristReq> pageParam, @Param("req") CustomOrderReceiptListTouristReq req);

    /**
     * 打印收据-旅客列表-统计
     * @param req
     * @return
     */
    @SelectProvider(type = SeriesOrderReceiptProvider.class, method = "selectCountListTouristBySelective")
    CustomOrderReceiptListTouristDTO selectCountListTouristBySelective(@Param("req") CustomOrderReceiptListTouristReq req);

    /**
     * 查询订单收据抬头
     * @param orderId
     * @return
     */
    @Select("SELECT receipt_header\n" +
            "FROM t_series_order_receipt\n" +
            "WHERE order_id = #{order_id} AND is_deleted = 0")
    String queryHeaderByOrder(@Param("order_id") Long orderId);
}
